const base = window.ROOTPATH || ''

const settings = {
	title: '',
	base,
	range: '~',
	prefix: `${base}/api/`,
	pageNumber: 'pageNumber',
	pageSize: 'pageSize',
	code: 200
}

export const pagination = {
	pageSize: 20,
	pageNumber: 1
}

export const getPagination = oldPagination => {
	const newPagination = {}
	const {
		pageNumber,
		pageSize
	} = oldPagination
	if (pageNumber != null) {
		newPagination[settings.pageNumber] = pageNumber
	}
	if (pageSize != null) {
		newPagination[settings.pageSize] = pageSize
	}
	return newPagination
}

export default {
	...settings,
	pagination: getPagination(pagination)
}